﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace EBookStore.UnitTests
{
    [TestFixture]
    [Category("Managers")]
    class Test_UsersManager
    {


        [TearDown]
        public void clear()
        {
            Management.UsersManager.Instance.Clear();
        }

        [Test]
        public void TestEquality()
        {
            Management.UsersManager u1 = Management.UsersManager.Instance;
            Management.UsersManager u2 = Management.UsersManager.Instance;

            Assert.AreEqual(u1, u2);
        }


        [Test]
        public void TestAddUser()
        {
            clear();
            Management.UsersManager u1 = Management.UsersManager.Instance;

            Users.User user = new Users.Customer("a", "a", ",a");
            u1.AddUser(user);
            Assert.AreEqual(1,u1.Users.Count);

            u1.RemoveUser(user);

            Assert.AreEqual(0, u1.Users.Count);

        }

        [Test]
        public void TestLogin()
        {
            Management.UsersManager u1 = Management.UsersManager.Instance;

            Users.User user = new Users.Customer("b", "b", ",b" ,"d","d");
            
            

            Assert.AreEqual(false, u1.Login(user.Login, user.Password));

            u1.AddUser(user);

            Assert.AreEqual(true, u1.Login(user.Login, user.Password));                

          

        }
    }
}
